package com.stx.day0918;

/**
 * packageName com.stx.day0918
 *
 * @author YangYi
 * @className ExceptionDemo
 * @date 2025/9/18
 * @description TODO
 */
public class ExceptionDemo {
    public static void main(String[] args) {
        int a = 10;
        int b = 0;
        int[] array = {1,2,3};
        try{// 执行代码
            System.out.println(array[4]);
            int de = a / b;
            System.out.println(de);
        }catch (ArithmeticException e){
            // 异常拦截处理，自行编写代码进行处理
            System.out.println("by zero");
            throw e;
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("下标异常");
        }finally {
            //不管catch里面是单独处理还是继续往外抛出异常，
            // 都会执行finally里面的代码
            System.out.println("处理完了");
        }
    }
}
